package com.xneure.code.plantask;

import java.util.Date;

public class TimingTask extends PlanTask{
	private Date starTime;
	private Date endTime;

	@Override
	public boolean checkParam(){
		boolean sTime = null != starTime && starTime.getTime() > System.currentTimeMillis();
		if(sTime){
			currRunCount = 0;
			return true;
		}else{
			return false;
		}
	}

	protected void tick(){
		++currRunCount;
	}

	@Override
	protected boolean isIgnore(){
			if(new Date(System.currentTimeMillis()).after(starTime)){
				return true;
			}else{
				return false;
			}
	}

	protected boolean isStop(){
		return (null != endTime && new Date(System.currentTimeMillis()).after(endTime));
	}

	@Override
	public void end(){
		currRunCount = 0;
	}

	/**
	 * 获取计划的开始时间 默认null
	 * 
	 * @return Date
	 */
	public Date getStarTime(){
		return starTime;
	}

	/**
	 * 设置开始时间
	 * 
	 * @param starTime void
	 */
	public void setStarTime(Date starTime){
		this.starTime = starTime;
	}

	/**
	 * 获取结束时间
	 * 
	 * @return Date
	 */
	public Date getEndTime(){
		return endTime;
	}

	/**
	 * 设置结束时间
	 * 
	 * @param endTime void
	 */
	public void setEndTime(Date endTime){
		this.endTime = endTime;
	}
}
